package com.j48.entrancegurad.controller;

import com.j48.entrancegurad.model.Host;
import com.j48.entrancegurad.model.Repair;
import com.j48.entrancegurad.service.IRepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;


/***
 * 添加保修数据
 */
@Controller
public class WxOpenDoorController {
    @Autowired
    private IRepairService repairService;
    @Autowired
    private com.j48.entrancegurad.service.IHostService hostService;

    /**
     * 一键开门，点击“确定”按钮
     * @param request
     * @param response
     * @return 返回结果
     * @throws IOException 输入输出异常
     */
    @RequestMapping(value = "/wxOpenDoor" ,produces = "text/html;charset=UTF-8")
    @ResponseBody
    public String wxRepairs(HttpServletRequest request, HttpServletResponse response) throws IOException{
        ArrayList<String> list = new ArrayList<>();
        list = (ArrayList<String>)request.getSession().getAttribute("HostList") ;
        int host_building=Integer.parseInt(list.get(0));//业主所属楼栋
        int host_unit=Integer.parseInt(list.get(1));//业主所属单元
        int host_housenumber=Integer.parseInt(list.get(2));//业主房间号
        Host host = new Host(host_building,host_unit,host_housenumber);//实例化对象host
        Host ht=hostService.selectByHouse(host);//查询
        if (ht!=null){
            return "true";
        }
        return  "false";
    }


}
